package com.lawliet.example.controller.system;

import com.lawliet.example.model.system.SysRolePermission;
import com.lawliet.example.model.vo.Result;
import com.lawliet.example.service.system.SysRolePermissionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "SysRolePermission 接口")
@RestController
@RequestMapping("/api/sysRolePermission")
public class SysRolePermissionController {
    @Autowired
    private SysRolePermissionService sysRolePermissionService;

    @GetMapping("/list")
    public Result<List<SysRolePermission>> list() {
        return Result.OK(sysRolePermissionService.list());
    }

    @PostMapping("/add")
    public Result<?> add(@RequestBody SysRolePermission sysRolePermission) {
        return Result.OK(sysRolePermissionService.save(sysRolePermission));
    }

    @PutMapping("/edit")
    public Result<?> edit(@RequestBody SysRolePermission sysRolePermission) {
        return Result.OK(sysRolePermissionService.updateById(sysRolePermission));
    }

    @DeleteMapping("/delete/{id}")
    public Result<?> delete(@PathVariable Long id) {
        return Result.OK(sysRolePermissionService.removeById(id));
    }

    @GetMapping("/query/{id}")
    public Result<SysRolePermission> queryById(@PathVariable Long id) {
        return Result.OK(sysRolePermissionService.getById(id));
    }
}
